---目标基类，目标不具有逻辑，子类需要实现本目标数据标签
---@class GoalBase
---@field label string  标签
---@field activeCondition State 激活条件
---@field effects State 影响
---@field agent AgentBase   代理
---@field onActivateCallFunc function 激活回调
---@field onInactivateCallFunc function 失效回调
---@field base GoalBase
GoalBase = class()

---@param agent AgentBase
function GoalBase:ctor(agent)
    self.base = GoalBase;
    self.agent = agent;
    self.label = self:GetLabel();
    if self.label == nil or self.label == "" then
        Debug.LogError("目标的标签出现空！")
    end
    self.effects = self:InitEffects();
    if self.effects == nil then
        Debug.LogError("目标的影响出现空！")
    end
    self.activeCondition = self:InitActiveCondition();
end

---获取标签，子类重写
function GoalBase:GetLabel() return "" end

---获取优先级，子类重写
function GoalBase:GetPriority() return 0; end

---初始化目标影响，子类重写
function GoalBase:InitEffects()
    local state = State.new();
    return state;
end

---初始化激活条件，子类重写
function GoalBase:InitActiveCondition()
    local state = State.new();
    return state;
end

---获取目标影响
function GoalBase:GetEffects()
    return self.effects;
end

---获取激活条件
function GoalBase:GetActiveCondition()
    return self.activeCondition;
end

---检查是否已经完成目标影响
function GoalBase:IsGoalComplete()
    return self.agent.agentState:ContainState(self.effects);
end

---设置目标激活时回调函数
function GoalBase:SetGoalActiveteCallFunc(callFunc)
    self.onActivateCallFunc = callFunc;
end

---设置目标失效时回调函数
function GoalBase:SetGoalInactivateCallFunc(callFunc)
    self.onInactivateCallFunc = callFunc;
end

---是否满足激活条件
function GoalBase:ActiveCondition()
    return self.agent.agentState:ContainState(self.activeCondition)
end

---更新数据时调用
function GoalBase:UpdateData()
    --Debug.Log("---"..self.label.."激活条件："..tostring(self:ActiveCondition()));
    if self:ActiveCondition() then
        self.onActivateCallFunc(self);
    else
        self.onInactivateCallFunc(self);
    end
end

function GoalBase:Release()

end